package com.googlecode.tapestry5validator.hibernate.adapters;

import java.lang.annotation.Annotation;
import java.util.Map;

import org.hibernate.validator.NotNull;

import com.googlecode.tapestry5validator.hibernate.ValidatorAdapter;

/**
 * {@link NotNull} adapter
 * 
 * @author Valentine Yerastov 
 */
public class NotNullAdapter implements ValidatorAdapter {

	@Override
	public Object fetchToJSParametrs(Map<String, Object> annotationParameters) {
		return null;
	}

	@Override
	public Class<? extends Annotation> getAnnotationClass() {
		return NotNull.class;
	}

	@Override
	public String getJSMethod() {
		//reuse tapestry
		return "required";
	}

	@Override
	public String getValidatorType() {
		return "hv-notNull";
	}

	@Override
	public boolean isRequired() {
		//Вызываем валидацию, даже если значение полу пусто или null
		return true;
	}

}
